package com.kfm.system.service.impl;

import com.kfm.common.domain.entity.Role;
import com.kfm.common.util.SecurityUtils;
import com.kfm.system.mapper.RoleMapper;
import com.kfm.system.service.RolesService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class RolesServiceImpl implements RolesService{

    @Resource
    private RoleMapper rolesMapper;

    @Override
    public int deleteByPrimaryKey(Integer roleId) {
        return rolesMapper.deleteByPrimaryKey(roleId);
    }

    @Override
    public int insert(Role record) {
        return rolesMapper.insert(record);
    }

    @Override
    public int insertSelective(Role record) {
        // 获取登录用户的id
        record.setCreatedById(SecurityUtils.getUserId());
        return rolesMapper.insertSelective(record);
    }

    @Override
    public Role selectByPrimaryKey(Integer roleId) {
        return rolesMapper.selectByPrimaryKey(roleId);
    }

    @Override
    public int updateByPrimaryKeySelective(Role record) {
        return rolesMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Role record) {
        return rolesMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<Role> selectByCondition(Role role) {
        return rolesMapper.selectByCondition(role);
    }

}
